package com.gxa.modules.worktable.controller;

import com.gxa.modules.community.util.Result;
import com.gxa.modules.worktable.entity.Journals;
import com.gxa.modules.worktable.entity.RepairAmount;
import com.gxa.modules.worktable.service.JournalService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


@Api(tags = "控制台接口")
@RestController
@Slf4j
public class JournalController {

    @Autowired
    private JournalService journalService;

    @ApiOperation(value="数据")
    @GetMapping("/journal/list")
    public Result<Journals> houseLabelList(){
        Result<Journals> r = new Result<>();
        try {
            Journals journals = journalService.queryHouseHoldTotal();
            r = Result.success(journals);
        }catch (Exception e){
            e.printStackTrace();
            r = Result.failed();
        }
        return r;
    }

    @ApiOperation(value="一周报修量数据")
    @GetMapping("/journal/repairList")
    public Result<List<RepairAmount>> repairList(){
        Result<List<RepairAmount>> r = new Result<>();
        try {
            List<RepairAmount> repairAmounts = this.journalService.queryRepair();
            r=Result.success(repairAmounts);
        }catch (Exception e){
            e.printStackTrace();
            r = Result.failed();
        }
        return r;
    }
}
